<template>
  <a-row :gutter="10">

      <a-card :bordered="false">

        <!-- 查询区域 -->
        <div class="table-page-search-wrapper">
          <a-form layout="inline" @keyup.enter.native="searchQuery">
            <a-row :gutter="24">

              <a-col :xl="6" :lg="7" :md="8" :sm="24">
                <a-form-item label="物资名称">
                  <a-input placeholder="请输入物资名称" v-model="queryParam.name"></a-input>
                </a-form-item>
              </a-col>
              <a-col :xl="6" :lg="7" :md="8" :sm="24">
                <a-form-item label="规格型号">
                  <a-input placeholder="请输入规格型号" v-model="queryParam.specifications"></a-input>
                </a-form-item>
              </a-col>
              <a-col :xl="6" :lg="7" :md="8" :sm="24">
                <a-form-item label="单位">
                  <a-input placeholder="请输入单位" v-model="queryParam.unit"></a-input>
                </a-form-item>
              </a-col>
              <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <!--              <a @click="handleToggleSearch" style="margin-left: 8px">-->
              <!--                {{ toggleSearchStatus ? '收起' : '展开' }}-->
              <!--                <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />-->
              <!--              </a>-->
            </span>
              </a-col>

            </a-row>
          </a-form>
        </div>

        <!-- 操作按钮区域 -->
        <div class="table-operator">
          <a-button v-has="'assetFixed:export'" type="primary" icon="download" @click="handleExportXls('固定资产')">导出
          </a-button>
        </div>

        <!-- table区域-begin -->
        <div>
          <a-table
            ref="table"
            size="middle"
            bordered
            rowKey="id"
            :columns="columns"
            :dataSource="dataSource"
            :pagination="ipagination"
            :loading="loading"
            class="j-table-force-nowrap"
            :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
            :scroll="{ x: 3000, y: screenHeight }"
            @change="handleTableChange">

            <template slot="imgSlot" slot-scope="text">
              <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
              <img v-else :src="getImgView(text)" height="25px" alt=""
                   style="max-width:80px;font-size: 12px;font-style: italic;" />
            </template>

          </a-table>
        </div>
        <!-- table区域-end -->
      </a-card>
  </a-row>

</template>

<script>
import '@/assets/less/TableExpand.less'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { getAction, deleteAction } from '@/api/manage'
import JSelectCategory from '../../components/jeecgbiz/JSelectCategory'
import { activitiMixin } from '@views/activiti/mixins/activitiMixin'
import { mixinDevice } from '@/utils/mixin'

export default {
  name: 'AssetFixedStatistical',
  mixins: [activitiMixin, JeecgListMixin, mixinDevice],
  components: {
    JSelectCategory
  },
  data () {
    return {
      description: '固定资产折旧',
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          }
        },
        {
          title: '物资名称',
          align: 'center',
          dataIndex: 'name'
        },
        {
          title: '规格型号',
          align: 'center',
          ellipsis: true,
          dataIndex: 'specifications'
        },
        {
          title: '所属单位',
          align: 'center',
          dataIndex: 'assetFixedCategoryId_dictText'
        },
        {
          title: '单位',
          align: 'center',
          dataIndex: 'unit'
        },
        {
          title: '数量',
          align: 'center',
          dataIndex: 'amount'
        },
        {
          title: '单价',
          align: 'center',
          dataIndex: 'price'
        },
        {
          title: '合价',
          align: 'center',
          dataIndex: 'total'
        },
        {
          title: '状态',
          align: 'center',
          dataIndex: 'status_dictText'
        },
        {
          title: '采购部门',
          align: 'center',
          dataIndex: 'purchasingDepartment'
        },
        {
          title: '采购日期',
          align: 'center',
          dataIndex: 'purchaseDate'
        },
        {
          title: '图片',
          align: 'center',
          dataIndex: 'image',
          scopedSlots: { customRender: 'imgSlot' }
        },
        {
          title: '材质说明',
          align: 'center',
          dataIndex: 'description'
        },
        {
          title: '楼层',
          align: 'center',
          dataIndex: 'floor'
        },
        {
          title: '尺寸',
          align: 'center',
          dataIndex: 'assetSize'
        },
        {
          title: '款式',
          align: 'center',
          dataIndex: 'assetStyle'
        },
        {
          title: '技术参数',
          align: 'center',
          dataIndex: 'technicalParameters'
        },
        {
          title: '品牌',
          align: 'center',
          dataIndex: 'brand'
        },
        {
          title: '备注',
          align: 'center',
          ellipsis: true,
          dataIndex: 'remark'
        },
        {
          title: '原值',
          align: 'center',
          dataIndex: 'originalCost'
        },
        {
          title: '累计折扣',
          align: 'center',
          dataIndex: 'accumulativeDiscount'
        },
        {
          title: '净残值率',
          align: 'center',
          dataIndex: 'residualValueRate'
        },
        {
          title: '净残值',
          align: 'center',
          dataIndex: 'residualValue'
        },
        {
          title: '折旧方法',
          align: 'center',
          dataIndex: 'depreciationMethod_dictText'
        },
        {
          title: '月折旧率',
          align: 'center',
          dataIndex: 'monthDepreciationRate'
        },
        {
          title: '月折旧额',
          align: 'center',
          dataIndex: 'monthDepreciation'
        },
        {
          title: '预计使用年限',
          align: 'center',
          dataIndex: 'expectedServiceLife'
        },
      ],
      url: {
        list: '/zcgl/assetFixed/list',
        delete: '/zcgl/assetFixed/delete',
        deleteBatch: '/zcgl/assetFixed/deleteBatch',
        exportXlsUrl: 'zcgl/assetFixed/exportXls',
        importExcelUrl: 'zcgl/assetFixed/importExcel',
        exportXlsTemplate: 'zcgl/assetFixed/exportXlsTemplate'
      },
    }
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    }
  },
  methods: {
    loadData (arg) {
      if (!this.url.list) {
        this.$message.error('请设置url.list属性!')
        return
      }
      //加载数据 若传入参数1则加载第一页的内容
      if (arg === 1) {
        this.ipagination.current = 1
      }
      var params = this.getQueryParams()//查询条件
      this.loading = true
      getAction(this.url.list, params).then((res) => {
        console.log(this.url.list + ':')
        console.log(res)
        if (res.success) {
          this.dataSource = res.result.records
          this.ipagination.total = res.result.total
        }
        if (res.code === 510) {
          this.$message.warning(res.message)
        }
        this.loading = false
      })
    },
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>